//
//  PDDHomeTableViewCell.m
//  PDDriver
//
//  Created by wangjian on 2016/11/30.
//  Copyright © 2016年 PD. All rights reserved.
//

#import "PDDHomeTableViewCell.h"

@implementation PDDHomeTableViewCell


//自定义cell
+(instancetype)mainbasictableviewcell:(UITableView *)tableview withrueseid:(NSString *)reuseid  andindexpath:(NSIndexPath *)indexpath{
    
    PDDHomeTableViewCell *cell = [tableview dequeueReusableCellWithIdentifier:reuseid];
    if (cell ==nil) {
        
        cell = [[PDDHomeTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseid];
        
    }
    
    cell.indexpath =indexpath;
    
    return cell;
    
}

//首页
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.BighelloLabel = [[UILabel alloc]init];
        self.BighelloLabel.text = @"你好";
        self.BighelloLabel.font = font(17);
        self.SmalltitleLabel = [[UILabel alloc]init];
        self.SmalltitleLabel.text = @"发布行程,匹配货源";
        self.SmalltitleLabel.font = font(15);
        
        self.ReleaseButton =[UIButton setTite:@"发布空车" setTitleColor:DHRGB(238, 238, 238)  HighlightedsetTitleColor:[UIColor redColor] backgroundColor:DHRGB(53, 53, 53) setFont:15 setcornerRadius:6];
        
        self.LookupButton = [UIButton setTite:@"查找货源" setTitleColor:DHRGB(53, 53, 53)  HighlightedsetTitleColor:[UIColor redColor] backgroundColor:DHRGB(252, 214, 54) setFont:15 setcornerRadius:6];
        
        self.CustomerserviceButton = [UIButton buttonWithType:UIButtonTypeCustom];
        
        //修改图片颜色
        self.CustomerserviceButton.tintColor = DHRGB(133, 140, 147);
        
        UIImage  *image =  [[UIImage imageNamed:@"22"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        
        [self.CustomerserviceButton setImage:image forState:UIControlStateNormal];
        
        
        [self.CustomerserviceButton setTitle:@"客服" forState:UIControlStateNormal];
        
        [self.CustomerserviceButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        
        self.CustomerserviceButton.titleLabel.font =  [UIFont systemFontOfSize:14];
        
         [self addSubview:self.BighelloLabel];
        
        [self addSubview:self.SmalltitleLabel];
        
        [self addSubview:self.ReleaseButton];
        
        [self addSubview:self.LookupButton];
        
        [self addSubview:self.CustomerserviceButton];
        
        
        NSInteger  i = SCREEN_WIDTH / 50;
        
        NSLog(@"%ld",i);
        
        
        [self.BighelloLabel  mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.mas_top).offset(8);
            make.left.mas_equalTo(self.mas_left).offset(8);
            make.size.mas_equalTo(CGSizeMake(60, 30));
            
        }];
        
        [self.SmalltitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.BighelloLabel.mas_bottom).offset(2);
            make.left.mas_equalTo(self.mas_left).offset(8);
            make.size.mas_equalTo(CGSizeMake(160, 30));
            
        }];
        
        [self.ReleaseButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.SmalltitleLabel.mas_bottom).offset(2);
            make.left.mas_equalTo(self.mas_left).offset(i);
            make.size.mas_equalTo(CGSizeMake((SCREEN_WIDTH - 8*8)/2,40));
        }];
        
        [self.LookupButton mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.centerY.mas_equalTo(self.ReleaseButton);
            make.right.mas_equalTo(self.mas_right).offset(-8);
            make.size.mas_equalTo(CGSizeMake((SCREEN_WIDTH - 8*8)/2,40));
            
        }];
        
        [self.CustomerserviceButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.mas_right).offset(-8);
            make.top.mas_equalTo(self.mas_top).offset(8);
            make.size.mas_equalTo(CGSizeMake(40, 60));
        }];
        
    }
    
    //修改客服中心button的样式
    
    [self.CustomerserviceButton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleTop imageTitleSpace:1.0];
    
    
    return self;
    
    }
@end
